/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.PA165.musiclibrarybackend.transfers;

import cz.muni.fi.PA165.musiclibraryapi.dto.SongDTOInterface;
import cz.muni.fi.PA165.musiclibrarybackend.dto.SongDTO;
import cz.muni.fi.PA165.musiclibrarybackend.entities.Song;

/**
 *
 * @author Tibor
 */
public class SongT {
    
    public static SongDTOInterface SongToDTO(Song song){
        if (song == null) {
            throw new IllegalArgumentException();
        }
        SongDTO songDTO = new SongDTO();
        
        songDTO.setAlbum(AlbumT.AlbumToDTO(song.getAlbumId()));
        songDTO.setAuthor(AuthorT.AuthorToDTO(song.getAuthorId()));
        songDTO.setBitrate(song.getBitrate());
        songDTO.setComment(song.getComment());
        songDTO.setGenre(GenreT.GenreToDTO(song.getGenreId()));
        songDTO.setName(song.getName());
        songDTO.setId(song.getId());
        songDTO.setSongOrder(song.getSongOrder());
                
        return songDTO;        
    }
    
    public static Song DTOtoSong(SongDTOInterface songDTO){
        if (songDTO == null) {
            throw new IllegalArgumentException();
        }
        Song song = new Song();
        
        song.setAlbumId(AlbumT.DTOtoAlbum(songDTO.getAlbum()));
        song.setAuthorId(AuthorT.DTOtoAuthor(songDTO.getAuthor()));
        song.setBitrate(songDTO.getBitrate());
        song.setComment(songDTO.getComment());
        song.setGenreId(GenreT.DTOtoGenre(songDTO.getGenre()));
        song.setName(songDTO.getName());
        song.setId(songDTO.getId());
        song.setSongOrder(songDTO.getSongOrder());
        
        return song;  
    }
}
